package com.sohu.sip.auth.dao.hibernate;

import java.util.List;

import org.hibernate.Query;

import com.sohu.peak.gallery.dao.hibernate.BaseHibernateDAO;
import com.sohu.peak.gallery.domain.Pic;
import com.sohu.peak.util.Logger;
import com.sohu.sip.auth.dao.AdminUserDAO;
import com.sohu.sip.auth.po.AdminUser;

public class AdminUserHibernateDAO extends BaseHibernateDAO implements AdminUserDAO{
	private static final Logger log = new Logger();
	
	
	public List findByProperty(String propertyName, Object value) {
		try {
			String queryString = "from AdminUser as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public AdminUser getByName(String username) {
		List list=this.findByProperty("username", username);
		if(list.size()>0){
			return (AdminUser)list.get(0);
		}else{
			return null;
		}
	}
	
}
